package com.qingcheng.controller;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author:boy
 * @Date:2019/7/16
 * @description:
 * @ModifiedBy:
 */
@RestController
@RequestMapping("/login")
public class LoginController {
    @RequestMapping("/username")
    public Map username(){
        String name = SecurityContextHolder.getContext().getAuthentication().getName();
        if ("anonymousUser".equals(name)){
            name="";
        }
        System.out.println(name);
        Map map=new HashMap();
        map.put("username",name);
        return map;
    }
}
